<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息管理系统 - 登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --error-color: #f72585;
            --light-color: #f8f9fa;
            --dark-color: #212529;
            --success-color: #4cc9f0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .login-container {
            width: 100%;
            max-width: 420px;
            background: white;
            padding: 2.5rem;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            animation: fadeIn 0.5s ease-in-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .logo {
            text-align: center;
            margin-bottom: 1.5rem;
        }

        .logo img {
            height: 60px;
        }

        .logo h1 {
            color: var(--primary-color);
            margin-top: 0.5rem;
            font-size: 1.5rem;
            font-weight: 600;
        }

        .form-group {
            margin-bottom: 1.25rem;
            position: relative;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--dark-color);
            font-weight: 500;
            font-size: 0.9rem;
        }

        .form-group input {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            transition: all 0.3s ease;
        }

        .form-group input:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
            outline: none;
        }

        .form-group .input-icon {
            position: absolute;
            right: 1rem;
            top: 2.4rem;
            color: #adb5bd;
        }

        .remember-forgot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            font-size: 0.85rem;
        }

        .remember-me {
            display: flex;
            align-items: center;
        }

        .remember-me input {
            margin-right: 0.5rem;
        }

        .forgot-password a {
            color: var(--primary-color);
            text-decoration: none;
        }

        .forgot-password a:hover {
            text-decoration: underline;
        }

        .login-btn {
            width: 100%;
            padding: 0.75rem;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .login-btn:hover {
            background-color: var(--secondary-color);
        }

        .error-message {
            color: var(--error-color);
            text-align: center;
            margin: 1rem 0;
            font-size: 0.9rem;
            animation: shake 0.5s;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-5px); }
            75% { transform: translateX(5px); }
        }

        .footer {
            text-align: center;
            margin-top: 1.5rem;
            color: #6c757d;
            font-size: 0.8rem;
        }

        /* 新版角色选择按钮样式 */
        .user-type-selector {
            display: flex;
            gap: 12px;
            margin: 1.5rem 0;
        }

        .user-type-btn {
            flex: 1;
            padding: 0.8rem 0.5rem;
            border: none;
            background: white;
            cursor: pointer;
            font-weight: 500;
            color: #555;
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            text-align: center;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .user-type-btn::before {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: transparent;
            transition: all 0.3s ease;
        }

        .user-type-btn i {
            font-size: 1.4rem;
            margin-bottom: 6px;
            color: var(--primary-color);
            transition: all 0.3s ease;
        }

        .user-type-btn.active {
            color: var(--primary-color);
            font-weight: 600;
            box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15);
            transform: translateY(-2px);
        }

        .user-type-btn.active::before {
            background: var(--primary-color);
        }

        .user-type-btn.active i {
            transform: scale(1.1);
        }

        .user-type-btn:hover:not(.active) {
            box-shadow: 0 4px 8px rgba(67, 97, 238, 0.1);
            transform: translateY(-2px);
        }

        .user-type-btn:active {
            transform: translateY(0) scale(0.98);
        }

        /* 响应式设计 */
        @media (max-width: 480px) {
            .login-container {
                padding: 1.5rem;
                margin: 0 1rem;
            }

            .user-type-selector {
                flex-direction: column;
                gap: 8px;
            }

            .user-type-btn {
                padding: 0.7rem;
            }
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
<div class="login-container">
    <div class="logo">
        <i class="fas fa-graduation-cap" style="font-size: 3rem; color: var(--primary-color);"></i>
        <h1>学生信息管理系统</h1>
    </div>

    <!-- 用户类型选择 -->
    <div class="user-type-selector">
        <button type="button" class="user-type-btn active" data-type="student">
            <i class="fas fa-user-graduate"></i>
            学生
        </button>
        <button type="button" class="user-type-btn" data-type="teacher">
            <i class="fas fa-chalkboard-teacher"></i>
            教师
        </button>
        <button type="button" class="user-type-btn" data-type="admin">
            <i class="fas fa-user-shield"></i>
            管理员
        </button>
    </div>

    <form action="${pageContext.request.contextPath}/user/login" method="post" id="loginForm">
        <input type="hidden" name="userType" id="userType" value="student">

        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" placeholder="请输入用户名" required>
            <i class="fas fa-user input-icon"></i>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" placeholder="请输入密码" required>
            <i class="fas fa-lock input-icon"></i>
        </div>

        <div class="remember-forgot">
            <div class="remember-me">
                <input type="checkbox" id="remember" name="remember">
                <label for="remember">记住我</label>
            </div>
            <div class="forgot-password">
                <a href="#">忘记密码?</a>
            </div>
        </div>

        <c:if test="${param.error == 'true'}">
            <div class="error-message">
                <i class="fas fa-exclamation-circle"></i> 用户名或密码错误!
            </div>
        </c:if>

        <button type="submit" class="login-btn">登录</button>
    </form>

    <div class="footer">
        <p>© 2023 学生信息管理系统 | 版本 2.0</p>
        <p>没有账号? <a href="/user/register">立即注册</a></p>
    </div>
</div>

<script>
    // 用户类型选择逻辑
    document.querySelectorAll('.user-type-btn').forEach(btn => {
        btn.addEventListener('click', function() {
            document.querySelectorAll('.user-type-btn').forEach(b => b.classList.remove('active'));
            this.classList.add('active');
            document.getElementById('userType').value = this.dataset.type;

            // 添加点击动画
            this.style.transform = 'translateY(0) scale(0.95)';
            setTimeout(() => {
                this.style.transform = 'translateY(-2px)';
            }, 150);
        });
    });
</script>
</body>
</html>